package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-05-29
 * Time: 12:45
 */

import java.util.Comparator;

/**
 * 解决问题：换一个接口解决：根据不同的属性进行比较，不用重新修改已经写好的类 ->
 */
public class AgeComparator implements Comparator<Student> {
    @Override
    public int compare(Student o1, Student o2) {
        return o1.age - o2.age;
    }
}
